package com.learning.spring.data.orm.dao.design.service.impl;

import com.learning.spring.data.orm.dao.design.dao.UserDao;
import com.learning.spring.data.orm.dao.design.entity.User;
import com.learning.spring.data.orm.dao.design.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName: UserServiceImpl
 * Description:
 * Date: 2020/7/22 16:19 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Transactional(rollbackFor = Exception.class,
        isolation = Isolation.DEFAULT,
        propagation = Propagation.REQUIRED)
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserDao userDao;

    /**
     * 新增
     *
     * @param user
     * @return
     */
    @Override
    public int add(User user) {
        return userDao.save();
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int delete(int id) {

        return 0;
    }

    @Override
    public int update(User user) {
        return 0;
    }

    @Transactional(rollbackFor = Exception.class,
            isolation = Isolation.DEFAULT,
            propagation = Propagation.REQUIRED,
            readOnly = true, timeout = 10000)
    @Override
    public User select(int id) {
        return null;
    }
}
